package com.h117121.fashionshop.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.h117121.fashionshop.core.dom.Producer;
import com.h117121.fashionshop.core.dom.ProductType;

public class UpdateSimpleDomValidator implements Validator {

	@SuppressWarnings("rawtypes")
	@Override
	public boolean supports(Class clazz) {
		return (Producer.class.isAssignableFrom(clazz) || ProductType.class
				.isAssignableFrom(clazz));
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name",
				"required.name");
	}

}
